/***************************************************************************
 *   Copyright (C) 2007 by Alexandre Masselot,,,   *
 *   alex@alex-laptop   *
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU Library General Public License as       *
 *   published by the Free Software Foundation; either version 2 of the    *
 *   License, or (at your option) any later version.                       *
 *                                                                         *
 *   This program is distributed in the hope that it will be useful,       *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 *   GNU General Public License for more details.                          *
 *                                                                         *
 *   You should have received a copy of the GNU Library General Public     *
 *   License along with this program; if not, write to the                 *
 *   Free Software Foundation, Inc.,                                       *
 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
 ***************************************************************************/
#include <assert.h>
#include "peptidepmffactory.h"

namespace bol{
  PeptidePMFFactory::PeptidePMFFactory():PeptideFactory()
  {
  }


  PeptidePMFFactory::~PeptidePMFFactory()
  {
  }


  void PeptidePMFFactory::setPeptideModifier(PeptideModifier* theValue){
    PeptideFactory::setPeptideModifier(theValue);
  //defines the fix transition
    for (int i=0; i<29; i++){
      m_varAAMapping[i]=NULL;
      if(!peptideModifier()->charMapper()[i])
        continue;
      if(peptideModifier()->charMapper()[i][1]==0){
      //there is no choice for the amino acid
        m_fixAAMapping[i]=peptideModifier()->charMapper()[i][0];
      }else{
      //check that the first modified aa is itself in the case of multipe choices (this means it is a variable modif)
        assert(peptideModifier()->charMapper()[i][0]==(unsigned char)i);
        int n=0;
        for(unsigned char *c=peptideModifier()->charMapper()[i]; *c; c++){
          n++;
        }
        m_varAAMapping[i]=new unsigned char[n+1];
        n=0;
        for(unsigned char *c=peptideModifier()->charMapper()[i]; *c; c++){
          m_varAAMapping[i][n++]=*c;
        }
        m_varAAMapping[i][n]=0;
      }
    }
  }

/*
The mechanism is the following:

*/
  void PeptidePMFFactory::createPeptides(Peptide& src, vector<PeptidePMF>& vpept){
    // TODO : hum... it's empty.
    // someone should put something here.

    // crash
    cerr << "not implemented yet !!!" << endl;
    exit(2);
  }
}
